#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll N=1e3+3,H=1e9+7;
ll n,m,ans,Fa[N],len[N],out[N],tmp[N],f[N];
int F(int x){return f[x]==x?x:f[x]=F(f[x]);}
void Mer(int x,int y){if(F(x)!=F(y))f[F(x)]=F(y);}
bool fl,vis[N];
vector<int>ve[N],G[N];
void Add(ll &x,ll y){x=(x+y)%H;}
void Len(int x)
{
	len[x]=1;
	for(int y:ve[x])if(y!=Fa[x])
		Fa[y]=x,Len(y),len[x]=max(len[x],len[y]+1);
}
int Out(int x,int fa)
{
	int s=1;
	for(int y:ve[x])if(y!=fa)s=max(s,Out(y,x)+1);
	return s;
}
void Get(int x,int fa,int z,int w)
{
	if(z==m)return Mer(x,w);
	for(int y:ve[x])if(y!=fa)Get(y,x,z+1,w);
}
int main()
{
	freopen("life.in","r",stdin);
	freopen("life.out","w",stdout);
	cin>>n>>m;ll res=1;
	for(int i=1,x,y;i<n;i++)cin>>x>>y,ve[x].push_back(y),ve[y].push_back(x);
	for(int i=1;i<=n;i++)
	{
		int mx1=0,mx2=0;
		for(int j:ve[i])
		{
			int d=Out(j,i);
			if(d>mx1)mx2=mx1,mx1=d;
			else if(d>mx2)mx2=d;
		}
		if(mx1+mx2+1>=m)vis[i]=1;
	}
	for(int i=1;i<=n;i++)if(!vis[i])res=res*2%H;
	if(!count(vis+1,vis+n+1,1)){cout<<res;return 0;}
	for(int i=1;i<=n;i++)if(vis[i])for(int j:ve[i])if(vis[j])G[i].push_back(j);
	for(int i=1;i<=n;i++)if(vis[i])f[i]=i;
	for(int i=1;i<=n;i++)if(vis[i])Get(i,0,0,i);
	ll s=0;
	for(int i=1;i<=n;i++)if(F(i)==i)s++;
	cout<<res*s%H;
	//cerr<<n<<" "<<m<<" "<<count(vis+1,vis+n+1,1)<<endl;
}
